package tests;

import common.Utils;
import org.openqa.selenium.By;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 */
public class RegisterPage extends Utils {
    public static String url = "http://49.235.61.184/?s=user/regInfo.html";

    public RegisterPage() {
        super(url);
    }
    /**
     * 注册页面可以正常打开
     */
    public void checkRegisterPage() throws IOException {
        //检查标题-欢迎注册
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.nav-seasrch.header-nav-simple > div > p.login-title.am-fl.am-vertical-align-middle.am-margin-left-main"));
        //检查账号注册中的输入框
        //用户名框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input"));
        //密码框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input"));
        //验证码框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input"));

        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button"));
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
    /**
     * 测试一：注册成功
     */
    public void registerSuc() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        //driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
        Thread.sleep(2000);
        //输入用户名
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).sendKeys("1167");
        //输入登陆密码
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).sendKeys("123456");
        Thread.sleep(5000);
        //输入验证码 - 手动输入
        /*driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).sendKeys("");*/
        //勾选阅读并同意前的方框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.agreement.am-margin-top-main > label")).click();
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
        Thread.sleep(1000);
        //退出登录
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.header-top > div > ul.top-nav-left.top-nav-left-content.am-hide-sm-only > div > div > em.logout > a")).click();

    }


    /**
     * 测试二：注册失败-用户名为空
     */
    public void registerFile1() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
        //输入登陆密码
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).sendKeys("123456");
        Thread.sleep(5000);
        //勾选阅读并同意前的方框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.agreement.am-margin-top-main > label")).click();
        Thread.sleep(3000);
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
    /**
     * 测试三：注册失败-输入的用户名已存在
     */
    public void registerFile2() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        //driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
        Thread.sleep(2000);
        //输入用户名
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).sendKeys("xiaohe");
        //输入登陆密码
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).sendKeys("123456");
        Thread.sleep(5000);
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }

    /**
     * 测试四：注册失败-输入的登录密码为空
     */
    public void registerFile3() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        //driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
        Thread.sleep(2000);
        //输入用户名
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).sendKeys("xiaohe");
        Thread.sleep(5000);
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
    /**
     * 测试五：注册失败-输入的登录密码不符合要求
     */
    public void registerFile4() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        //driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
        Thread.sleep(2000);
        //输入用户名
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).sendKeys("xiaohe");
        //输入登陆密码
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).sendKeys("12345");
        Thread.sleep(5000);
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());

    }
    /**
     * 测试六：注册失败-输入的验证码为空
     */
    public void registerFile5() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
        Thread.sleep(2000);
        //输入用户名
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).sendKeys("xiaohe");
        //输入登陆密码
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).sendKeys("123456");
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
    /**
     * 测试七：注册失败-未勾选同意协议
     */
    public void registerFile6() throws InterruptedException, IOException {
        //清空输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).clear();
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(3) > input")).clear();
       //取消同意协议
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.agreement.am-margin-top-main > label")).click();
        Thread.sleep(2000);
        //输入用户名
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(1) > input")).sendKeys("xiaohe");
        //输入登陆密码
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div:nth-child(2) > input")).sendKeys("123456");
        Thread.sleep(5000);
        //点击注册按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div.am-g.user-register-container.theme-data-edit-event > div > div > div.am-radius-lg.am-background-white > div > div.am-tabs-bd.am-border-0 > div.am-tab-panel.am-active > form > div.am-form-group.am-margin-top-main.am-padding-0 > button")).click();
        Thread.sleep(1000);
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());

    }

}
